﻿using Microsoft.OpenApi.Extensions;
using Modules.Constructor;
using Modules.Corp;
using Modules.Person;
using Modules.Project;
using Modules.System;
using Modules.System.AppNotice;
using Modules.System.Menu;
using Modules.Template;
using PmSoft;
using PmSoft.Entity;
using System.IO;
using System.Reflection.Emit;
using System.Text;
using static Modules.CheckIn.CheckInDetailConstants;
using static Modules.BankSpecialAccount.BankSpecialAccountConstants;
using static Modules.Notify.NotifyConstants;
using static Modules.Person.PersonConstants;
using static Modules.Device.CheckInDeviceConstants;
using static Modules.System.Flow.FlowConstants;
using static Modules.Payroll.PayrollConstants;
using Modules.System.EarlyWarning;
using PmSoft.Utilities;
using Modules.FaceScan;
using Modules.SMS;

namespace ManagementApi.Models.Common
{
    public class DictResultDto
    {
        public string Version { get; set; }
        public DictDto Dict { get; set; }
    }

    /// <summary>
    /// 字典模型
    /// </summary>
    public class DictDto
    {
        private static string directory = "Config";
        private static string dictPath = "Dict";
        //static DictDto()
        //{
        //    LoadBankTypeDIC();
        //}

        /// <summary>
        /// 建设单位类型字典
        /// </summary>
        public IEnumerable<LabelValue<int>> ConstructorTypes { get; set; } = Enum.GetValues<ConstructorType>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 企业经济类型字典
        /// </summary>
        public IEnumerable<LabelValue<int>> CorpEconomicTypes { get; set; } = Enum.GetValues<CorpEconomicType>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 法人职务字典
        /// </summary>
        public IEnumerable<LabelValue<int>> LegalManDutyTypes { get; set; } = Enum.GetValues<LegalManDutyTypes>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 法人职称字典
        /// </summary>
        public IEnumerable<LabelValue<int>> LegalManTitleTypes { get; set; } = Enum.GetValues<LegalManTitleTypes>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 行政级别字典
        /// </summary>
        public IEnumerable<LabelValue<int>> AdministrativeLevels { get; set; } = Enum.GetValues<AdministrativeLevel>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 项目状态
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectStatus { get; set; } = Enum.GetValues<ProjectConstants.项目状态>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 企业分类
        /// </summary>
        public IEnumerable<LabelValue<int>> CorpTypes { get; set; } = Enum.GetValues<企业分类>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 人员性别
        /// </summary>
        public IEnumerable<LabelValue<int>> Gender { get; set; } = Enum.GetValues<工人性别字典>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 工人政治面貌
        /// </summary>
        public IEnumerable<LabelValue<int>> PoliticsType { get; set; } = Enum.GetValues<工人政治面貌>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 工人文化程度
        /// </summary>
        public IEnumerable<LabelValue<int>> CultureLevel { get; set; } = Enum.GetValues<工人文化程度>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 工人婚姻状况
        /// </summary>
        public IEnumerable<LabelValue<int>> MaritalStatus { get; set; } = Enum.GetValues<工人婚姻状况>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        ///App通知公告类型
        /// </summary>
        public IEnumerable<LabelValue<int>> AppNoticeType { get; set; } = Enum.GetValues<通知公告类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 流程步骤
        /// </summary>
        public IEnumerable<LabelValue<int>> FlowEngine { get; set; } = Enum.GetValues<FlowEngine>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 用户登录类型
        /// </summary>
        public IEnumerable<LabelValue<int>> UserType { get; set; } = Enum.GetValues<UserType>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        #region 工资明细

        /// <summary>
        /// 考勤状态
        /// </summary>
        public IEnumerable<LabelValue<int>> CheckInStatus { get; set; } = Enum.GetValues<考勤状态>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 进出标识
        /// </summary>
        public IEnumerable<LabelValue<int>> EntryExitMark { get; set; } = Enum.GetValues<进出标识>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 数据来源
        /// </summary>
        public IEnumerable<LabelValue<int>> DataSources { get; set; } = Enum.GetValues<数据来源>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 工资单类型
        /// </summary>
        public IEnumerable<LabelValue<int>> WageType { get; set; } = Enum.GetValues<工资单类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        #endregion 工资明细

        #region 项目

        /// <summary>
        /// 项目分类
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectCategorys { get; set; } = Enum.GetValues<ProjectConstants.项目分类>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 项目立项级别
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectApprovalLevel { get; set; } = Enum.GetValues<ProjectConstants.项目立项级别>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 项目建设规模类型
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectSizeTypes { get; set; } = Enum.GetValues<ProjectConstants.项目建设规模类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 项目建设性质分类
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectPropertys { get; set; } = Enum.GetValues<ProjectConstants.项目建设性质分类>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 工程用途
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectFunctions { get; set; } = Enum.GetValues<ProjectConstants.工程用途>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 项目参加单位类型
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectCorpTypes { get; set; } = Enum.GetValues<项目参建单位类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 项目承建状态
        /// </summary>
        public IEnumerable<LabelValue<int>> ConstructionStatus { get; set; } = Enum.GetValues<承建状态>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 项目资金来源
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectFundsSource { get; set; } = Enum.GetValues<ProjectConstants.项目资金来源>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 项目审核状态
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectAuditStatus { get; set; } = Enum.GetValues<ProjectConstants.项目审核状态>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 项目行业主管部门
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectIndustryTypes { get; set; } = Enum.GetValues<行业主管部门>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 工种
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectGropuMemberTypeWork { get; set; } = Enum.GetValues<工人工种>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 工人类型
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectGropuMemberTypeWorker { get; set; } = Enum.GetValues<工人类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 管理岗位
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectGropuMemberManageType { get; set; } = Enum.GetValues<管理岗位类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        #endregion 项目

        /// <summary>
        /// 民族
        /// </summary>
        public IEnumerable<LabelValue<int>> ChineseEthnicity { get; set; } = Enum.GetValues<民族>().Select(m => new LabelValue<int> { Label = m.GetDisplayName(), Value = (int)m });

        /// <summary>
        /// 行政区划
        /// </summary>
        public IEnumerable<VueTree<int>> AreaTrees { get; set; } = new List<VueTree<int>>();

        /// <summary>
        /// 行业分类及项目分类
        /// </summary>
        public IEnumerable<VueTree<int>> IndustryTypes { get; set; } = new List<VueTree<int>>();

        /// <summary>
        /// 扫描来源类型
        /// </summary>
        public IEnumerable<LabelValue<int>> FaceScanReferType { get; set; } = Enum.GetValues<FaceScanReferType>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 考勤设备厂家
        /// </summary>
        public IEnumerable<LabelValue<int>> ProjectCheckInDeviceType { get; set; } = Enum.GetValues<考勤设备设备厂家>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 考勤机命令
        /// </summary>
        public IEnumerable<LabelValue<int>> CheckInCommandType { get; set; } = Enum.GetValues<考勤机命令>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 短信类型
        /// </summary>
        public IEnumerable<LabelValue<int>> SmsMsgType { get; set; } = Enum.GetValues<MsgType>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        public IEnumerable<LabelValue<string>> BankTypeTypes { get; set; }

        public IEnumerable<LabelValue<string>> BankSubbranchs { get; set; }

        #region 保证金

        /// <summary>
        /// 收支类型
        /// </summary>
        public IEnumerable<LabelValue<int>> IncomeType { get; set; } = Enum.GetValues<收支类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 交易类型
        /// </summary>
        public IEnumerable<LabelValue<int>> TradingType { get; set; } = Enum.GetValues<交易类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 缴存类型
        /// </summary>
        public IEnumerable<LabelValue<int>> DepositeType { get; set; } = Enum.GetValues<缴存类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 收支方式
        /// </summary>
        public IEnumerable<LabelValue<int>> IncomeWay { get; set; } = Enum.GetValues<收支方式>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 工资支付方式
        /// </summary>
        public IEnumerable<LabelValue<int>> PayMentType { get; set; } = Enum.GetValues<工资支付方式>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        #endregion 保证金

        /// <summary>
        /// 审批状态
        /// </summary>
        public IEnumerable<LabelValue<int>> CheckStatus { get; set; } = Enum.GetValues<审批状态>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 专户状态
        /// </summary>
        public IEnumerable<LabelValue<int>> AccountStatus { get; set; } = Enum.GetValues<专户状态>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 支付方式
        /// </summary>
        public IEnumerable<LabelValue<int>> PaymentMethod { get; set; } = Enum.GetValues<支付方式>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 通知类型
        /// </summary>
        public IEnumerable<LabelValue<int>> LimitReaderType { get; set; } = Enum.GetValues<可见对象类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 模板类型
        /// </summary>
        public IEnumerable<LabelValue<int>> TemplateType { get; set; } = Enum.GetValues<模板类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 合同类型
        /// </summary>
        public IEnumerable<LabelValue<int>> ContractType { get; set; } = Enum.GetValues<合同类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 工资计算方式
        /// </summary>
        public IEnumerable<LabelValue<int>> SalaryCalculationMethod { get; set; } = Enum.GetValues<工资计算方式>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 工资卡类型
        /// </summary>
        public IEnumerable<LabelValue<int>> PersonCardType { get; set; } = Enum.GetValues<工资卡类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 预警类型
        /// </summary>
        public IEnumerable<LabelValue<int>> WarningType { get; set; } = Enum.GetValues<预警类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 考勤设备设备厂家
        /// </summary>
        public IEnumerable<LabelValue<int>> DeviceProvider { get; set; } = Enum.GetValues<考勤设备设备厂家>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 密码强度
        /// </summary>
        public IEnumerable<LabelValue<int>> PasswordStrength { get; set; } = Enum.GetValues<PasswordStrength>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 工资单代发状态
        /// </summary>
        public IEnumerable<LabelValue<int>> WageStatus { get; set; } = Enum.GetValues<代发状态>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 实例
        /// </summary>
        public static DictDto Instance = new DictDto();

        #region 人员证书字典

        /// <summary>
        /// 证书字典类型
        /// </summary>
        public IEnumerable<LabelValue<int>> PersonCertificateType { get; set; } = Enum.GetValues<证书字典类型>().Select(m => new LabelValue<int> { Label = m.GetDescription(), Value = (int)m });

        /// <summary>
        /// 证书字典Trees
        /// </summary>
        public IEnumerable<VueTree<string>> PersonCertificateTrees { get; set; } = new List<VueTree<string>>();

        #endregion 人员证书字典

        /// <summary>
        /// 银行字典
        /// </summary>
        public IEnumerable<LabelValue<string>> LoadBankTypeDIC()
        {
            List<LabelValue<string>> BankTypeDic = new List<LabelValue<string>>();
            var lines = File.ReadAllLines(Path.Combine(Environment.CurrentDirectory, directory, dictPath, "住建银行代码字典表.txt"), Encoding.UTF8);
            foreach (var line in lines)
            {
                var cols = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                BankTypeDic.Add(new LabelValue<string> { Value = cols[1].Trim(), Label = cols[0] });
            }
            return BankTypeDic;
        }

        /// <summary>
        /// 支行字典
        /// </summary>
        public IEnumerable<LabelValue<string>> LoadBankSubbranchDIC()
        {
            List<LabelValue<string>> BankSubbranchDIC = new List<LabelValue<string>>();
            var lines = File.ReadAllLines(Path.Combine(Environment.CurrentDirectory, directory, dictPath, "开户支行字典表.txt"), Encoding.UTF8);
            foreach (var line in lines)
            {
                var cols = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                BankSubbranchDIC.Add(new LabelValue<string> { Value = cols[0], Label = cols[1].Trim() });
            }
            return BankSubbranchDIC;
        }
    }
}